<?php

use yii\helpers\Html;
use yii\grid\GridView;
use common\models\CommentStatus;
/* @var $this yii\web\View */
/* @var $searchModel common\models\CommentSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */

$this->title = '评论管理';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="comment-index">

    <h1><?= Html::encode($this->title) ?></h1>
    <?php // echo $this->render('_search', ['model' => $searchModel]); ?>

   
    <?= GridView::widget([
        'dataProvider' => $dataProvider,
        'filterModel' => $searchModel,
        'columns' => [
//          ['class' => 'yii\grid\SerialColumn'],

            ['attribute'=>'id',
            'contentOptions'=>['width'=>'30px'],
            ],
//          'content:ntext',
            ['attribute'=>'content',
            'value'=>'beginning',
//           'value'=>function($model){
//           	$tmpStr=strip_tags($model->content);//html标签去掉
//              $tmpLen=mb_strlen($tmpStr);//统计长度
//              return mb_substr($tmpStr,0,20,'utf-8').($tmpLen>20?'...':'');
//           }
            ],
            ['attribute'=>'user.username',
             'label'=>'作者',
             'value'=>'user.username',
            ],
            ['attribute'=>'status',
            'value'=>'status0.name',
            'filter'=>CommentStatus::find()
                     ->select(['name','id'])
                     ->orderBy('position')
                     ->indexBy('id')
                     ->column(),
            ],
            'create_time:datetime',
           
            // 'email:email',
            // 'url:url',
            // 'post_id',

            ['class' => 'yii\grid\ActionColumn'],
        ],
    ]); ?>
</div>
